import request from "./request";

export class TagApi {
  static getAll(params): Promise<ITag[]> {
    return request.get("/tag", { params });
  }
  static getTagWithArticles(id, needFilter): Promise<ITag> {
    return request.get(
      `/tag/${id}/article`,
      needFilter ? { params: { status: "publish" } } : {}
    );
  }
  static add(data): Promise<ITag> {
    return request.post("/tag", data);
  }
  static update(id, data): Promise<ITag> {
    return request.patch(`/tag/${id}`, data);
  }
  static delete(id): Promise<ITag> {
    return request.delete(`/tag/${id}`);
  }
}
